import config from "@/config"
import http from "@/utils/request"
export const showPageApi = {
    url: `${config.BASE_URL}/reservesoldiers/information/select`,
    name: "展示页面数据",
    get: async function(data){
        return await http.get(`${this.url}?pageNum=${data.pageNum}&pageSize=${data.pageSize}`);
    }
}


export const deleteApi= {
    url: `${config.BASE_URL}/reservesoldiers/information/deleteById`,
    name: "删除单条数据",
    delete: async function(volunteerInfoId){
        return await http.delete(`${this.url}?volunteer_info_id=${volunteerInfoId}`);
    }
}

export const allDeleteApi= {
    url: `${config.BASE_URL}/reservesoldiers/information/delete`,
    name: "批量删除",
    delete: async function(data){
        return await http.delete(`${this.url}`,data);
    }
}


export const editFormInfoApi= {
    url: `${config.BASE_URL}/reservesoldiers/information/selectById`,
    name: "获取编辑数据的信息",
    get: async function(id){
        return await http.get(`${this.url}?volunteer_info_id=${id}`);
    }
}
export const editFormApi= {
    url: `${config.BASE_URL}/reservesoldiers/information/update`,
    name: "点击确定按钮成功编辑",
    put: async function(id,data){
        return await http.put(`${this.url}?volunteer_info_id=${id}`,data);
    }
}

// 导出兵役信息列表
export async function exportApi() {
    let res = await fetch(`${config.BASE_URL}/reservesoldiers/information/export`, {
        method: 'post',
        headers: {
            'Content-Type': 'application/json',
        }
    }).then(res => res.blob()).then(data => {
        var blobUrl = window.URL.createObjectURL(data);
        return blobUrl
    })
    return res
}

// 查询接口没写
export const singleSearchApi= {
    url: `${config.BASE_URL}/reservesoldiers/information/selectByFile`,
    name: "单字段查询",
    get: async function(content,field){
        return await http.get(`${this.url}?content=${content}&field=${field}`);
    }
}

export const allSearchApi= {
    url: `${config.BASE_URL}/reservesoldiers/information/selectvolunteer`,
    name: "高级查询",
    post: async function(data){
        return await http.post(`${this.url}?name=${name}`,data);
    }
}
